# functions specific to your project
#         * makeUname             - create unique user name 
#         * getUname              - retrieve from file
#         * makeUserFileName      - create server-specific file for users
#         * initServer            - initialize the server string and authentication
#         * myLogin               - login to the given/default server 
#
#########################################################################

# Define global variables for specific to your project. 

prodUser="bashWebTest"
stageUser="bashWebTest"
pwd="mypassword"
defaultserver="www.netscrap.com"
emailSuffix="netscrap.com"

function initServer {
	echo "initializing the server:"
	
	server=${1-"$defaultserver"}
	if echo $server | grep -q "prod" || echo $server | grep -q $defaultserver
		then
			echo no authentication necessary for $defaultserver
	fi
	echo "server: $server"
	export web
	export server
	export u_switch
	export authentic
	
	[ ! -d "$testoutput" ] && mkdir "$testoutput"
}


# make a new user name:
function makeUname {
	# TODO: where does the variable notProd come from?
	#       it is not defined in any of the bwt files.
 	if [ `expr $notProd : "true"` -gt 0 ] ; then 	
		# TODO: where does the RANDOM variable get set?
		#       it is not defined in any of the bwt files.
		token=`date +%Y%m%d-%H%M_%S`$RANDOM
		echo "uname=$token"
		echo "placing $token into $userFileName"
	 	echo $token >> $userFileName
	 	uname=$token
	else
		uname=$prodUser
	fi
	export uname
}

# get user name:
function getUname {
	# TODO: where does the variable notProd come from?
	#       it is not defined in any of the bwt files.
	if [ `expr $notProd : "true"` -gt 0 ] ; then 	
	 	uname=`tail -1 $userFileName`
		echo "user: $uname"
	else
		if echo $server | grep -q "prod" || echo $server | grep -q "www.netscrap.com" 
		then
			uname=$prodUser
		elif echo $server | grep -q "stage"
		then 
			uname=$stageUser
		fi
	fi
	export uname
}


#
# In this file, you'll want to set up some functions specific to 
# your project. Here's a search function for a feature that takes a
# search term. 
# 
#########################################################################

